home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ASM-F.ZIP / FREE.ASM < prev    next >
Assembly Source File  |  1986-06-05  |  4KB  |  112 lines

  1.           title  FREE.ASM
  2.           page,132
  3.  
  4. cseg      segment para 'code'
  5.           assume cs:cseg
  6. main      proc   far
  7.           org    100h
  8. start:
  9.           jmp    begin
  10.  
  11. banner    db     0ah,'FREE Vers 1.0 - Sept. 1985 - by Art Merrill',0dh,0ah,'$'
  12.           db     'Copyright (C) 1985',0dh,0ah,'$'
  13.           db     'Ziff-Davis Publishing Company',0dh,0ah,'$'
  14. total:    db     0ah,8 dup(0),' bytes total disk space',0dh,0ah
  15. diff:     db     8 dup(0),' bytes allocated',0dh,0ah
  16. bytes:    db     8 dup(0),' bytes available on disk',0dh,0ah,0ah,'$'
  17. hltotal:  dw     0,0
  18. hlbytes:  dw     0,0
  19.  
  20. begin:
  21.           mov    dx,offset banner
  22.           mov    ah,9
  23.           int    21h
  24.  
  25.           mov    si,5ch                ;address of selected drive
  26.           mov    dl,[si]
  27.           mov    ah,36h                ;get disk free space
  28.           int    21h
  29.  
  30.           push   ax                    ;save for total bytes
  31.           push   cx                    ;save for total bytes
  32.           push   dx                    ;save for total bytes
  33.  
  34.           mul    bx                    ;get total clusters
  35.           mul    cx                    ;get total bytes
  36.  
  37.           std
  38.           mov    di,offset hlbytes+2
  39.           xchg   ax,dx
  40.           stosw
  41.           xchg   ax,dx
  42.           stosw
  43.  
  44.           mov    di,offset bytes+7     ;storage for ascii printout
  45.           call   ascii
  46.  
  47.           pop    dx                    ;get back total clusters
  48.           pop    cx                    ;get back bytes per sector
  49.           pop    ax                    ;get back sectors per cluster
  50.  
  51.           mul    dx                    ;total clusters
  52.           mul    cx                    ;bytes per sector
  53.  
  54.           mov    di,offset hltotal+2   ;same routine as above to get
  55.           xchg   ax,dx                 ;  total bytes
  56.           stosw
  57.           xchg   ax,dx
  58.           stosw
  59.  
  60.           mov    di,offset total+8     ;storage for ascii printout
  61.           call   ascii
  62.  
  63.           mov    ax,word ptr hltotal+2 ;calculate difference between
  64.           sub    ax,word ptr hlbytes+2 ;  total bytes and bytes allocated
  65.           xchg   ax,dx                 ;  to get total bytes remaining
  66.           mov    ax,word ptr hltotal
  67.           sub    ax,word ptr hlbytes
  68.           jnc    skip
  69.           dec    dx                    ;adjust total for carry
  70. skip:
  71.           mov    di,offset diff+7      ;storage for ascii printout
  72.           call   ascii
  73.  
  74.           mov    dx,offset total       ;print results
  75.           mov    ah,9
  76.           int    21h
  77.  
  78.           int    20h                   ;exit
  79.  
  80. main      endp
  81.  
  82. ascii     proc   near
  83.           xchg   bp,dx                 ;save high word
  84.           mov    bx,0ah                ;divisor
  85.           mov    cl,30h                ;conversion for ascii
  86. rpt1:
  87.           cmp    bp,0                  ;are we done with high words
  88.           jz     rpt2                  ;yes
  89.           xchg   ax,bp                 ;no-get high word
  90.           xor    dx,dx                 ;clear dx
  91.           div    bx
  92.           xchg   bp,ax                 ;this will be the new high word
  93.           div    bx                    ;divide low word + remainder
  94.           or     dl,cl                 ;convert hex value to ascii
  95.           mov    [di],dl               ;quotient into storage
  96.           dec    di                    ;step back one byte
  97.           jmp    rpt1                  ;go again
  98. rpt2:
  99.           xor    dx,dx                 ;clear dx
  100.           div    bx
  101.           or     dl,cl                 ;convert hex value to ascii
  102.           mov    [di],dl               ;quotient into storage
  103.           dec    di                    ;step back one byte
  104.           cmp    ax,0                  ;are we done?
  105.           jnz    rpt2                  ;no
  106.  
  107.           ret                          ;yes
  108. ascii     endp
  109.  
  110. cseg      ends
  111.           end    start
  112.